package com.fingard.avatar.website.service.impl;

import com.fingard.avatar.website.config.UserContext;
import com.fingard.avatar.website.model.po.SysUploadPo;
import com.fingard.avatar.website.dao.SysUploadMapper;
import com.fingard.avatar.website.service.SysUploadService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.time.LocalDateTime;

/**
 *  Service实现类
 *
 * @author 徐一涛
 * @date 2022-04-27
 */
@Slf4j
@Service
public class SysUploadServiceImpl extends ServiceImpl<SysUploadMapper, SysUploadPo> implements SysUploadService {

    @Override
    public SysUploadPo add(String fileName, String newName, String fileUrl) {
        SysUploadPo upload = new SysUploadPo().setFileName(fileName).setNewName(newName).setFileUrl(fileUrl).
                setCreateTime(LocalDateTime.now()).setCreateBy(UserContext.getUserId());

        save(upload);
        return upload;
    }
}
